using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The TeacherSubjectTableManager class is responsible for managing BO.TeacherSubjectTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class TeacherSubjectTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all TeacherSubjectTable objects in the database.
        /// </summary>
        /// <returns>A list with all TeacherSubjectTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static TeacherSubjectTableList GetList(int teacherProfileKey)
        {
            return TeacherSubjectTableDB.GetList(teacherProfileKey);
        }

        /// <summary>
        /// Gets a single TeacherSubjectTable from the database without its data.
        /// </summary>
        /// <param name="teachderSubjectKey">The TeachderSubjectKey of the TeacherSubjectTable in the database.</param>
        /// <returns>A TeacherSubjectTable object when the TeachderSubjectKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static TeacherSubjectTable GetItem(int teacherSubjectKey)
        {
            return GetItem(teacherSubjectKey, false);
        }

        /// <summary>
        /// Gets a single TeacherSubjectTable from the database without its data.
        /// </summary>
        /// <param name="teachderSubjectKey">The TeachderSubjectKey of the TeacherSubjectTable in the database.</param>
        /// <returns>A TeacherSubjectTable object when the TeachderSubjectKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static TeacherSubjectTable GetItem(int teacherProfileKey, int subjectKey)
        {
            return TeacherSubjectTableDB.GetItem(teacherProfileKey, subjectKey);
        }

        /// <summary>
        /// Gets a single TeacherSubjectTable from the database.
        /// </summary>
        /// <param name="teachderSubjectKey">The TeachderSubjectKey of the TeacherSubjectTable in the database.</param>
        /// <param name="getTeacherSubjectTableRecords">Determines whether to load all associated TeacherSubjectTable records as well.</param>
        /// <returns>
        /// A TeacherSubjectTable object when the TeachderSubjectKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static TeacherSubjectTable GetItem(int teacherSubjectKey, bool getTeacherSubjectTableRecords)
        {
            TeacherSubjectTable myTeacherSubjectTable = TeacherSubjectTableDB.GetItem(teacherSubjectKey);
            return myTeacherSubjectTable;
        }

        /// <summary>
        /// Saves a TeacherSubjectTable in the database.
        /// </summary>
        /// <param name="myTeacherSubjectTable">The TeacherSubjectTable instance to save.</param>
        /// <returns>The new TeachderSubjectKey if the TeacherSubjectTable is new in the database or the existing TeachderSubjectKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(TeacherSubjectTable myTeacherSubjectTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int teacherSubjectTableTeachderSubjectKey = TeacherSubjectTableDB.Save(myTeacherSubjectTable);

                //  Assign the TeacherSubjectTable its new (or existing TeachderSubjectKey).
                myTeacherSubjectTable.TeacherSubjectKey = teacherSubjectTableTeachderSubjectKey;

                myTransactionScope.Complete();

                return teacherSubjectTableTeachderSubjectKey;
            }
        }

        /// <summary>
        /// Deletes a TeacherSubjectTable from the database.
        /// </summary>
        /// <param name="myTeacherSubjectTable">The TeacherSubjectTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(int teacherSubjectKey)
        {
            return TeacherSubjectTableDB.Delete(teacherSubjectKey);
        }

        #endregion

    }

}
